package com.lf.emv;



import com.jiangdg.usbcamera.utils.Lf_Debug;

import java.io.UnsupportedEncodingException;

public class jni {
    public static int READERCARD = 5;//0-1902 1-SSLF 2-SS1902 3-rk3399开发板 4-rk3399_pro盛世达 5-8953 龙尚
	public static int gl_HardVer = 0;
    public static int gl_ProductType = 0;   //0-z03t, 1-285, 2-286
    
    public static final int FONT_SIZE8 = 8;       //  小字体显示(6*8) 无汉字
    public static final int FONT_SIZE12 = 12;      //  大字体显示(8*12) 汉字(12*12)
    public static final int FONT_SIZE16 = 16;      //  大字体显示(8*16) 汉字(16*16)
    public static final int FONT_SIZE24 = 24;      //  大字体显示(12*24) 汉字(24*24)
    public static final int FONT_SIZE32 = 32;      //  大字体显示(16*32) 汉字(32*32)
    public static final int FONT_SIZE48 = 48;      //  大字体显示(24*48) 汉字(48*48)
    public static final int DISP_CLRLINE = 0x100;   //  清除显示占用的行
    public static final int DISP_MEDIACY = 0x200;   //  居中显示
    public static final int DISP_INVCHAR = 0x400;   //  反白显示（字符）
    public static final int DISP_INVLINE = 0x800;   //  反白显示（整行）
    
    public static final int DISP_TOTAL5_FONT_LINE0 = 0;
    public static final int DISP_TOTAL5_FONT_LINE1 = 24;
    public static final int DISP_TOTAL5_FONT_LINE2 = 48;
    public static final int DISP_TOTAL5_FONT_LINE3 = 72;
    public static final int DISP_TOTAL5_FONT_LINE4 = 96;
    
    // 寻卡模式
    public static final int RFID_MODE_ISO = 0x00;   //ISO方式寻卡，可以从多张卡中寻到1张卡
    public static final int RFID_MODE_EMV = 0x01;   //EMV方式寻卡，只能有1张卡
    public static final int RFID_MODE_NOFRAME = 0x02;   //ISO方式寻卡，不判断卡端发送帧号
    public static final int RFID_MODE_TYPEA = 0x10;   //寻找TypeA卡
    public static final int RFID_MODE_TYPEB = 0x20;   //寻找TypeB卡
    public static final int RFID_MODE_ALL = (RFID_MODE_TYPEA | RFID_MODE_TYPEB);  //寻找2种卡
    public static final int RFID_MODE_MASK = 0x31;
    
    public static final int RFID_SUCCESS = 0;
    public static final int RFID_ERROR = 4601;          //打开模块失败
    public static final int RFID_ERRPARAM = 4602;       //参数错误
    public static final int RFID_TIMEOUT = 4603;        //超时
    public static final int RFID_NOCARD = 4604;         //无卡
    public static final int RFID_TRANSERR = 4605;       //卡片与读卡器之间通信错误
    public static final int RFID_PROTERR = 4606;        //卡片返回数据不符合ISO14443或者PAYPASS规范
    public static final int RFID_MULTIERR = 4607;       //感应区多卡存在
    public static final int RFID_NOACT = 4608;          //卡未上电
    public static final int RFID_CARDEXIST = 4609;      //卡未离开
    public static final int RFID_NOAUTH = 4610;         //未认证
    public static final int RFID_AUTHERR = 4611;        //认证失败
    public static final int RFID_UNCHANGE = 4612;       //不可修改
    public static final int RFID_KEYNOTPOWER = 4613;    //密钥无权限
    
    public static final int TFT_WHITE = 0xFFFF;
    public static final int TFT_BLACK = 0x0000;
    public static final int TFT_BLUE = 0x001F;
    public static final int TFT_BRED = 0XF81F;
    public static final int TFT_GRED = 0XFFE0;
    public static final int TFT_GBLUE = 0X07FF;
    public static final int TFT_RED = 0xF800;
    public static final int TFT_MAGENTA = 0xF81F;
    public static final int TFT_GREEN = 0x07E0;
    public static final int TFT_CYAN = 0x7FFF;
    public static final int TFT_YELLOW = 0xFFE0;
    public static final int TFT_BROWN = 0XBC40;
    public static final int TFT_BRRED = 0XFC07;
    public static final int TFT_GRAY = 0X8430;
    public static final int TFT_LIGHT_BLUE = 0xCF1F;
    
    public static final int POWER_MODE_BAT = 0x01;  //电池
    public static final int POWER_MODE_RFID = 0x02; //RFID射频
    public static final int POWER_MODE_ADAPTER = 0x03;
    public static final int POWER_MODE_POWEROFF = 0x04;
    public static final int POWER_MODE_LED = 0x05;      //LED灯
    public static final int POWER_MODE_WDT = 0x06;
    public static final int POWER_MODE_RST1902 = 0x07;
    
    public static final int COLOR_RED = 0x01;
    public static final int COLOR_BLUE = 0x02;
    public static final int COLOR_GREEN = 0x03;
    public static final int COLOR_YELLOW = 0x04;
    
    public static final int COLOR_ON = 0x01;
    public static final int COLOR_OFF = 0x02;
    
    public static int     USERCARD = 0x00;        // 半埋卡座
    public static int     SAM1SLOT = 0x01;        // SAM卡座1
    public static int     SAM2SLOT = 0x02;        // SAM卡座2
    public static int     SAM3SLOT = 0x03;      // SAM卡座3
    public static int     SAM4SLOT = 0x04;      // SAM卡座4
    
    // ICC卡通信参数
    public static int     VCC_5 = 0x05;    //  5V卡
    public static int     VCC_3 = 0x03;        //  3V卡
    public static int     VCC_18 = 0x01;       //  1.8V卡
    
    public static int     ISOMODE = 0x01;      // 符合ISO7816规范
    public static int     EMVMODE = 0x00;      // 符合EMV v4.1规范
    public static int     SHBMODE = 0x02;      // 社保规范
    public static int     CITYUNIONMODE = 0x03;
    
    //返回的电压状态
    public static int   POWER_STATUS_NULL = 0x00;       //电池检测未运行
    public static int   POWER_STATUS_CHARGE = 0x01;     //正在充电
    public static int   POWER_STATUS_FULL = 0x02;       //已经充满
    public static int   POWER_STATUS_NOBATT = 0x03;     //无电池
    public static int   POWER_STATUS_NEEDCHARGE = 0x04; //需要充电
    public static int   POWER_STATUS_SHUTDOWN = 0x05;   //需要关机
    public static int   POWER_STATUS_CHARGE2 = 0x06;     //正在充电（旧系统是判错误）
    public static int   POWER_STATUS_USEBATT = 0x07;       //当前电池电量够用
    public static int   POWER_STATUS_ERROR2 = 0x08;     //无电池，无适配器
    
//  定义按键值
    public final static int KEY0 = 0x30;    //  '0'
    public final static int KEY1 = 0x31;    //  '1'
    public final static int KEY2 = 0x32;    //  '2'
    public final static int KEY3 = 0x33;    //  '3'
    public final static int KEY4 = 0x34;    //  '4'
    public final static int KEY5 = 0x35;    //  '5'
    public final static int KEY6 = 0x36;    //  '6'
    public final static int KEY7 = 0x37;    //  '7'
    public final static int KEY8 = 0x38;    //  '8'
    public final static int KEY9 = 0x39;    //  '9'
    public final static int KEY_BACKSPACE = 0x08;    //  back
    public final static int KEY_CLEAR = 0x2E;
    public final static int KEY_SYMBOL = 0x13;
    public final static int KEY_ALPHA = 0x07;    //字母
    public final static int KEY_UP = 0x26;
    public final static int KEY_DOWN = 0x28;
    public final static int KEY_F1 = 0x15;
    public final static int KEY_F2 = 0x14;
    public final static int KEY_F3 = 0x16;
    public final static int KEY_F4 = 0x17;
    public final static int KEY_F8 = 0x18;
    public final static int KEY_ENTER = 0x0D;
    public final static int KEY_FUNC = 0x15;
    public final static int KEY_CANCEL = 0x1B;
    public final static int KEY_INVALID = 0xFF;
    public final static int KEY_TIMEOUT = 0x00;
    
    public static int   PRODUCT_SSLF_Z03T = 0x00;
    public static int   PRODUCT_SSLF_285 = 0x01;
    public static int   PRODUCT_SSLF_286 = 0x02;
    public static int   PRODUCT_SSLF_285IV = 0x03;
    public static int   PRODUCT_MAX = 0x04;
    
    class _BLKALTER2
    {
    	char mode;
    	char access;
    	char[] keyA=new char[6];
    	char[] keyB=new char[6];
    	char[] rfu=new char[2];
    	
    	int getlength()
    	{
    		int length=0;
    		length += 1;
    		length += 1;
    		length += keyA.length;
    		length += keyB.length;
    		length += rfu.length;
    		return length;
    	}
    	
    	char[] getdata()
    	{
    		int len=0;
    		char[] data = new char[getlength()];
    		data[len++] = mode;
    		data[len++] = access;
    		System.arraycopy(keyA, 0, data, len, keyA.length);
    		len+=keyA.length;
    		System.arraycopy(keyB, 0, data, len, keyB.length);
    		len+=keyB.length;
    		System.arraycopy(rfu, 0, data, len, rfu.length);
    		len+=rfu.length;
    		
    		return data;
    	}
    }

    private String[] gProductName = new String[]{
            "SSLF-Z03T",
            "SSLF-285",
            "SSLF-286"
        };
    
    private static jni instance = null;
    
    private jni() {}
    
	static{
		try {
			System.loadLibrary("emvjni");
	        
		} 
        catch (Throwable throwable) 
        {
        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
        }
		
		try {
	        System.loadLibrary("api");
	        
		} 
        catch (Throwable throwable) 
        {
        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
        }
		
		try {
			System.loadLibrary("commu");
	        
		} 
        catch (Throwable throwable) 
        {
        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
        }
		
		try {
			System.loadLibrary("emv");
	        
		} 
        catch (Throwable throwable) 
        {
        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
        }
		if(READERCARD != 4)
		{
			try {
				System.loadLibrary("inputflinger");
	        
			} 
	        catch (Throwable throwable) 
	        {
	        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
	        }
		}
		try {
			 System.loadLibrary("lcd");
	        
		} 
        catch (Throwable throwable) 
        {
        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
        }
		
		try {
			System.loadLibrary("mydes");
	        
		} 
        catch (Throwable throwable) 
        {
        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
        }
		
		try {
			System.loadLibrary("other");
	        
		} 
        catch (Throwable throwable) 
        {
        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
        }
		if(READERCARD != 4)
		{
			try {
				System.loadLibrary("sm2");
	        
			} 
	        catch (Throwable throwable) 
	        {
	        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
	        }
		
			try {
				 System.loadLibrary("sys");
	        
			} 
	        catch (Throwable throwable) 
	        {
	        	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
	        }
		}

	    try {
			System.loadLibrary("libc++_shared");
	        
		} 
	    catch (Throwable throwable) 
	    {
	    	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
	    }
	    
	    try {
			System.loadLibrary("wlt2bmp");
	        
		} 
	    catch (Throwable throwable) 
	    {
	    	Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "loadLibrary false!"+throwable.getMessage());
	    }
    }
    
    public static jni getInstance()
    {
        if (instance == null) {
            instance = new jni();
        }
        return instance;
    }
	//获取产品名称
	private static native void ProductTypeSet(int product);
    //获取版本号
    private static native int HardVerGet();
    
    
    public static void AppProductTypeSet(int product)
    {
        if(product < PRODUCT_MAX)
        {
            gl_ProductType = product;
            ProductTypeSet(product);
        }
    }
    
    public String AppProductName()
    {
        if(gl_ProductType < PRODUCT_MAX)
        {
            return gProductName[gl_ProductType];
        }
        else
        {
            return null;
        }
    }
    
    private native int MH1902Open();
    private native int MH1902Close();
    private native int MH1902Beep(int ms);
    public int MH1902_Open()
    {
        if(READERCARD != 1)
        {
            return MH1902Open();
        }
        else
        {
            return -1;
        }
    }
    
    public int MH1902_Close()
    {
        if(READERCARD != 1)
        {
            return MH1902Close();
        }
        else
        {
            return -1;
        }
    }

    public int MH1902_Beep(int ms)
    {
        if(READERCARD != 1)
        {
            return MH1902Beep(ms);
        }
        else
        {
            return -1;
        }
    }
  //射频卡操作
    private native int RfidSetField(int mode);
    private native int RfidGetRegValue(char addr, char[] value);
    private native int RfidSetReg(int mode);
    private native int RfidReg(char[] Reg);
    private native int RfidVersion(char[] version);
    private native int RfidOpen(int mode);
    private native int RfidClose();
    
    private native int RfidPoll(int mode, int[] cardtype);
    private native int RfidPowerup(int cardtype, int[] puiOutLen, char[] pvOut);
    private native int RfidExchangedata(int sendlen, char[] psenddata, int[] precvlen, char[] precvdata);
    private native int RfidPowerdown();
    
    private native int Rfid2Open(int mode);
    private native int Rfid2Close();
    private native int Rfid2Poll(int mode, int[] cardtype);
    private native int Rfid2Powerup(int cardtype, int[] puiOutLen, char[] pvOut);
    private native int Rfid2Exchangedata(int sendlen, char[] psenddata, int[] precvlen, char[] precvdata);
    private native int Rfid2Powerdown();
    
    private native int DlSecureKey(int index, char[] key, int keylen);
    private native int GetSecureKey(int index, char[] key, int[] keylen);
    private native int CheckSecureKey(int index);
    private native int UnlockSecureKey(int index);
    private native int CarderLedSet(int color, int onoff);
    
    public native int QrAuthReadData(int[] len, char[] data);
    public native int QrAuthWriteData(int len, char[] data);
    public native int QrAuthData(char[] sn);
    public native int AppReadData(int[] len, char[] data);
    public native int AppWriteData(int len, char[] data);
    
    private native int rfidm1auth(int sec, int keytype, char[] key);
    private native int rfidm1read(int block, char[] data);
    private native int rfidm1write(int block, char[] data);
    
    private native int rfidm1increment(int block, long value);
    private native int rfidm1decrement(int block, long value);
    private native int rfidm1restore(int block);
    private native int rfidm1transfer(int block);
    private native int rfidm1modify(int block, char[] data);
    private native int rfidm1makevalue(long value, int block, char[] out);
    
    private native int rfid2m1auth(int sec, int keytype, char[] key);
    private native int rfid2m1read(int block, char[] data);
    private native int rfid2m1write(int block, char[] data);
    
    private native int rfid2m1increment(int block, long value);
    private native int rfid2m1decrement(int block, long value);
    private native int rfid2m1restore(int block);
    private native int rfid2m1transfer(int block);
    private native int rfid2m1modify(int block, char[] data);
    private native int rfid2m1makevalue(long value, int block, char[] out);
    
    
    private native int cardRder_id_open();
    private native int cardRder_id_close();
    private native int cardRder_id_poll();
    private native int cardRder_id_active();
    private native int cardRder_id_read(char[] output, int[] datalen);
    private native int cardRder_id_read_finger_print(char[] output, int[] datalen);
    private native int cardRder_id_picunpack(char[]src, char[]dst, int bmpSave);
    
    public int cardRder_IdOpen()
    {
    	
    	if(READERCARD != 1)
		{
    		return cardRder_id_open();
		}
		else
		{
			return -1;
		}	
    }
    
    public int cardRder_IdClose()
    {
    	
    	if(READERCARD != 1)
		{
    		return cardRder_id_close();
		}
		else
		{
			return -1;
		}	
    }
    
    public int cardRder_IdPoll()
    {
    	
    	if(READERCARD != 1)
		{
    		return cardRder_id_poll();
		}
		else
		{
			return -1;
		}	
    }
    
    public int cardRder_IdActive()
    {
    	
    	if(READERCARD != 1)
		{
    		return cardRder_id_active();
		}
		else
		{
			return -1;
		}	
    }
    
    public int cardRder_IdRead(char[] output, int[] datalen)
    {
    	
    	if(READERCARD != 1)
		{
    		return cardRder_id_read(output, datalen);
		}
		else
		{
			return -1;
		}	
    }
    
    public int cardRder_IdReadFingerPrint(char[] output, int[] datalen)
    {
    	
    	if(READERCARD != 1)
		{
    		return cardRder_id_read_finger_print(output, datalen);
		}
		else
		{
			return -1;
		}	
    }
    
    
    public int cardRder_IdPicUnpack(char []src, char []dst, int bmpSave)
    {
    	if(READERCARD != 1)
		{
    		return cardRder_id_picunpack(src, dst, bmpSave);
		}
		else
		{
			return -1;
		}    
    	
    }

    public int App_ReadData(int[] len, char[] data)
    {
		if(READERCARD != 1)
		{
    		return AppReadData(len, data);
		}
		else
		{
			return -1;
		}	
    }
    
    public int App_WriteData(int len, char[] data)
    {
		if(READERCARD != 1)
		{
    		return AppWriteData(len, data);
		}
		else
		{
			return -1;
		}	
    }
    
    public int QrAuth_ReadData(int[] len, char[] data)
    {
		if(READERCARD != 1)
		{
    		return QrAuthReadData(len, data);
		}
		else
		{
			return -1;
		}	
    }
    
    public int QrAuth_WriteData(int len, char[] data)
    {
		if(READERCARD != 1)
		{
    		return QrAuthWriteData(len, data);
		}
		else
		{
			return -1;
		}	
    }
    
    public int QrAuth_Data(char[] sn)
    {
		if(READERCARD != 1)
		{
    		return QrAuthData(sn);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_version(char[] version)
    {
		if(READERCARD != 1)
		{
        	return RfidVersion(version);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_SetField(int mode)//0-打开 其他-关闭
    {
		if(READERCARD != 1)
		{
        	return RfidSetField(mode);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_Reg(char[] Reg)//N导  P导  调制深度
    {
		if(READERCARD != 1)
		{
        	return RfidReg(Reg);
		}
		else
		{
			return -1;
		}	
    }
    
	public int rfid_setReg(int mode)//0-285 2-神思 3-自定义
    {
        if(READERCARD != 1)
    	{
    		return RfidSetReg(mode);
    	}
    	else
    	{
    		return -1;
    	}
    }
	
	public int rfid_getRegValue(char addr, char[] value)//读取寄存器值
    {
        if(READERCARD != 1)
    	{
    		return RfidGetRegValue(addr, value);
    	}
    	else
    	{
    		return -1;
    	}
    }
	
    public int rfid_open(int mode)
    {
    	if(READERCARD == 0)
    	{
    		return RfidOpen(mode);
    	}
    	else
    	{
    		return RfidOpen(READERCARD);
    	}
    }
    public int rfid_close()
    {
        return RfidClose();
    }
    public int rfid_poll(int mode, int[] cardtype)
    {
        return RfidPoll(mode, cardtype);
    }
    public int rfid_powerup(int cardtype, int[] puiOutLen, char[] pvOut)
    {
        return RfidPowerup(cardtype, puiOutLen, pvOut);
    }
    public int rfid_exchangedata(int sendlen, char[] psenddata, int[] precvlen, char[] precvdata)
    {
        return RfidExchangedata(sendlen, psenddata, precvlen, precvdata);
    }
    public int rfid_powerdown()
    {
        return RfidPowerdown();
    }
    
    public int rfid2_open(int mode)
    {
    	return Rfid2Open(mode);	
    }
    public int rfid2_close()
    {
        return Rfid2Close();
    }
    public int rfid2_poll(int mode, int[] cardtype)
    {
        return Rfid2Poll(mode, cardtype);
    }
    public int rfid2_powerup(int cardtype, int[] puiOutLen, char[] pvOut)
    {
        return Rfid2Powerup(cardtype, puiOutLen, pvOut);
    }
    public int rfid2_exchangedata(int sendlen, char[] psenddata, int[] precvlen, char[] precvdata)
    {
        return Rfid2Exchangedata(sendlen, psenddata, precvlen, precvdata);
    }
    public int rfid2_powerdown()
    {
        return Rfid2Powerdown();
    }
    
    public int rfid_m1auth(int sec, int keytype, char[] key)//keytype:0-A 1-B
    {
    	if(READERCARD != 1)
		{
    		return rfidm1auth(sec, keytype, key);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_m1read(int block, char[] data)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfidm1read(block, data);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_m1write(int block, char[] data)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfidm1write(block, data);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_m1increment(int block, long value)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfidm1increment(block, value);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_m1decrement(int block, long value)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfidm1decrement(block, value);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_m1restore(int block)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfidm1restore(block);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_m1transfer(int block)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfidm1transfer(block);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_m1modify(int block, _BLKALTER2 data)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfidm1modify(block, data.getdata());
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid_m1makevalue(long value, int block, char[] out)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfidm1makevalue(value, block, out);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1auth(int sec, int keytype, char[] key)//keytype:0-A 1-B
    {
    	if(READERCARD != 1)
		{
    		return rfid2m1auth(sec, keytype, key);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1read(int block, char[] data)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfid2m1read(block, data);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1write(int block, char[] data)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfid2m1write(block, data);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1increment(int block, long value)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfid2m1increment(block, value);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1decrement(int block, long value)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfid2m1decrement(block, value);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1restore(int block)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfid2m1restore(block);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1transfer(int block)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfid2m1transfer(block);
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1modify(int block, _BLKALTER2 data)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfid2m1modify(block, data.getdata());
		}
		else
		{
			return -1;
		}	
    }
    
    public int rfid2_m1makevalue(long value, int block, char[] out)
    {
    	
    	if(READERCARD != 1)
		{
    		return rfid2m1makevalue(value, block, out);
		}
		else
		{
			return -1;
		}	
    }
    
    public int dl_secure_key(int index, char[] key, int keylen)
    {
        return DlSecureKey(index, key, keylen);
    }
    public int get_secure_key(int index, char[] key, int[] keylen)
    {
        return GetSecureKey(index, key, keylen);
    }
    public int check_secure_key(int index)
    {
        return CheckSecureKey(index);
    }
    public int unlock_secure_key(int index)
    {
        return UnlockSecureKey(index);
    }
    public int carder_led_set(int color, int onoff)
    {
        return CarderLedSet(color, onoff);
    }
    
    //PSAM卡接口
    public native int PsamReset();
    public native int PsamExchangedata(int sendlen, char[] psenddata, int[] precvlen, char[] precvdata);
    
    public int psam_reset()
    {
		if(READERCARD != 1)
		{
			return -1;
		}
		else
		{
        	return PsamReset();
		}
    }
    
    public int psam_exchangedata(int sendlen, char[] psenddata, int[] precvlen, char[] precvdata)
    {
		if(READERCARD != 1)
		{
			return -1;
		}
		else
		{
        	return PsamExchangedata(sendlen, psenddata, precvlen, precvdata);
		}
    }
    
    private native int CalcTdea(char[] src, char[] dst, char[] deskey, int keylen, int mode);
    private native void Hash(char[] DataIn, int DataInLen, char[] DataOut);
    
    public int calc_tdea(char[] src, char[] dst, char[] deskey, int keylen, int mode)
    {
        return CalcTdea(src, dst, deskey, keylen, mode);
    }
    
    public void BaseHash(char[] DataIn, int DataInLen, char[] DataOut)
    {
        Hash(DataIn, DataInLen, DataOut);
    }
    
    private native void LcdInit();
    private native void LcdCls();
    private native void LcdRect(int x, int y, int width, int height, int color);
    private native void LcdDisplay(int x, int y, int disp_mode, byte[] fmt);
    private native void LcdColorDisplay(int x, int y, int fontcolor, int backcolor, int disp_mode, byte[] fmt);
    private native int LcdBmpDisp(int x, int y, byte[] bmpdata);
    private native int LcdBmpDispEx(int x, int y, byte[] bmpdata);
    
    public void lcd_init()
    {
        LcdInit();
    }
    
    public void lcd_cls()
    {
        LcdCls();
    }
    
    public void lcd_rect(int x, int y, int width, int height, int color)
    {
        LcdRect(x, y, width, height, color);
    }
    
    public void lcd_display(int x, int y, int disp_mode, String format, Object... args)
    {
        String logstr;
        logstr = String.format(format, args);
        try {
            byte[] gbk = logstr.getBytes("GBK");
            LcdDisplay(x, y, disp_mode, gbk);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
    }
    
    public void lcd_color_display(int x, int y, int fontcolor, int backcolor, int disp_mode, String format, Object... args)
    {
        String logstr;
        logstr = String.format(format, args);
        try {
            byte[] gbk = logstr.getBytes("GBK");
            LcdColorDisplay(x, y, fontcolor, backcolor, disp_mode, gbk);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public int lcd_bmp_disp(int x, int y, String path)
    {
        int ret = 0;
        try {
            byte[] gbk = path.getBytes("GBK");
            ret = LcdBmpDisp(x, y, gbk);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return ret;
    }
    
    public int lcd_bmp_disp_ex(int x, int y, byte[] bitmap)
    {
        int ret;
        if(bitmap.length > 100 * 1024)
        {
            return -1;
        }
        ret = LcdBmpDispEx(x, y, bitmap);
        return ret;
    }
    
    
    
    private native int CtrlCommuOpen(int uart_id, int baud);
    private native int CtrlCommuClose(int uart_id);
    private native int CtrlCommuClear(int uart_id);
    private native int CtrlCommuRead(int uart_id, char[] outbuf, int bytelen, int timeout_ms);
    private native int CtrlCommuWrite(int uart_id, char[] inbuf, int bytelen);
    private native int CtrlCommuCheckReadBuf(int uart_id);
    private native int CtrlCommuPreRead(int uart_id, char[] outbuf, int bytelen);
    private native int CtrlCommuPreReadOne(int uart_id, char[] outbuf, int index);
    
    public int CtrlCommu_Open(int uart_id, int baud)
    {
        return CtrlCommuOpen(uart_id, baud);
    }
    
    public int CtrlCommu_Close(int uart_id)
    {
        return CtrlCommuClose(uart_id);
    }
    
    public int CtrlCommu_Clear(int uart_id)
    {
        return CtrlCommuClear(uart_id);
    }
    
    public int CtrlCommu_Read(int uart_id, char[] outbuf, int bytelen, int timeout_ms)
    {
        return CtrlCommuRead(uart_id, outbuf, bytelen, timeout_ms);
    }
    
    public int CtrlCommu_Write(int uart_id, char[] inbuf, int bytelen)
    {
        return CtrlCommuWrite(uart_id, inbuf, bytelen);
    }
    
    public int CtrlCommu_CheckReadBuf(int uart_id)
    {
        return CtrlCommuCheckReadBuf(uart_id);
    }
    
    public int CtrlCommu_PreRead(int uart_id, char[] outbuf, int bytelen)
    {
        return CtrlCommuPreRead(uart_id, outbuf, bytelen);
    }
    public int CtrlCommu_PreReadOne(int uart_id, char[] outbuf, int index)
    {
        return CtrlCommuPreReadOne(uart_id, outbuf, index);
    }
    
    private native int SaveKey(int id, char[] key, int keylen, int mode, int keyType);
    private native int GetKey(int id, char[] key, int keylen, int keyType);
    private native void SetPowerPin(int mode, int value);
    private native int GetPowerPin(int mode);
    
    public int Save_Key(int id, char[] key, int keylen, int mode, int keyType)
    {
        return SaveKey(id, key, keylen, mode, keyType);
    }
    
    public int Get_Key(int id, char[] key, int keylen, int keyType)
    {
        return GetKey(id, key, keylen, keyType);
    }
    
    public void Set_Power(int mode, int value)
    {
        SetPowerPin(mode, value);
    }
    
    public int Get_Power(int mode)
    {
        return GetPowerPin(mode);
    }
    
    private native void SetWdtPin(int value);
    private native void SetCopReset();
    
    public void Set_Wdt_Pin(int value)
    {
        SetWdtPin(value);
    }
    
    public void Set_Cop_Reset()
    {
        SetCopReset();
    }
    
    
    private native int QRInit();
    private native int QROpen();
    private native int QRClose();
    private native int QRGetHtml(char[] html, int waittime);
    private native int QRCheck();
    private native int QRBeep(int ms);
    
    public int QR_Init()
    {
        return QRInit();
    }
    
    public int QR_Open()
    {
        return QROpen();
    }
    
    public int QR_Close()
    {
        return QRClose();
    }
    
    public int QR_GetHtml(char[] html, int waittime)
    {
        return QRGetHtml(html, waittime);
    }
    
    public int QR_Check()
    {
        return QRCheck();
    }
    
    public int QR_Beep(int ms)
    {
        return QRBeep(ms);
    }
    
    private native int CarderDataCommu(int sendlen, char[] psenddata, int[] precvlen, char[] precvdata);
    
    public int Carder_DataCommu(int sendlen, char[] psenddata, int[] precvlen, char[] precvdata)
    {
        return CarderDataCommu(sendlen, psenddata, precvlen, precvdata);
    }
    
    public native int SslfDecrypt(char[] psenddata, int sendlen, char[] decryptdata, int[] decryptlen);
    
    public int SSLF_Decrypt(char[] psenddata, int sendlen, char[] decryptdata, int[] decryptlen)
    {
		if(READERCARD != 1)
		{
			return -1;
		}
		else
		{
        	return SslfDecrypt(psenddata, sendlen, decryptdata, decryptlen);
		}
    }

    private native int Carder1902DataOpen(int id, int bps);
    private native int Carder1902DataSend(int id, int sendlen, char[] psenddata);
    private native int Carder1902DataRecv(int id, int[] precvlen, char[] precvdata);
    private native int Carder1902DataCheckRecvBuf(int id);
    private native int Carder1902DataClear(int id);
    private native int Carder1902DataClose(int id);
    
    public int Carder_1902DataCommuOpen(int id, int bps)
    {
		if(READERCARD != 1)
		{
    		return Carder1902DataOpen(id, bps);
		}
		else
		{
			return -1;
		}
    }
    
    public int Carder_1902DataCommuSend(int id, int sendlen, char[] psenddata)
    {
		if(READERCARD != 1)
		{
    		return Carder1902DataSend(id, sendlen, psenddata);
		}
		else
		{
			return -1;
		}
    }
    
    public int Carder_1902DataCommuRecv(int id, int[] precvlen, char[] precvdata)
    {
		if(READERCARD != 1)
		{
    		return Carder1902DataRecv(id, precvlen, precvdata);
		}
		else
		{
			return -1;
		}
    }
    
    public int Carder_1902DataCommuCheckRecvBuf(int id)
    {
		if(READERCARD != 1)
		{
    		return Carder1902DataCheckRecvBuf(id);
		}
		else
		{
			return -1;
		}
    }
    
    public int Carder_1902DataCommuClear(int id)
    {
		if(READERCARD != 1)
		{
    		return Carder1902DataClear(id);
		}
		else
		{
			return -1;
		}
    }
    
    public int Carder_1902DataCommuClose(int id)
    {
		if(READERCARD != 1)
		{
    		return Carder1902DataClose(id);
		}
		else
		{
			return -1;
		}
    }
    
    public native int JniSysfile(int cmdlen, char[] cmd, int modelen, char[] mode);
    public native int JniSystem(int cmdlen, char[] cmd);
    public native int JniSync(int mode);
    
    public void Jni_System(int cmdlen, char[] cmd)
    {
		if(READERCARD != 1)
		{
			//Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "cmd:"+new String(CharUtil.getBytes(cmd)));
    		JniSystem(cmdlen, cmd);
		}
    }
    
    public void Jni_Sysfile(int cmdlen, char[] cmd, int modelen, char[] mode)
    {
		if(READERCARD != 1)
		{
			//Lf_Debug.dbg_mPrintf(Lf_Debug._FILE_LINE_FUNC_(), "echo "+new String(CharUtil.getBytes(cmd))+">"+new String(CharUtil.getBytes(mode)));
			JniSysfile(cmdlen, cmd, modelen, mode);
		}
    }
    
    public void Jni_Sync(int mode)
    {
		if(READERCARD != 1)
		{
    		JniSync(mode);
		}
    }
    
    public native int cardRder_iccInit(int CardSlot, int CardVol, int CardMode);  
    public native int cardRder_iccSelectSlot(int CardSlot);
    public native int cardRder_iccCheckVcc(int CardSlot);
    public native int cardRder_iccCheckInSlot(int CardSlot);
    public native int cardRder_iccReset(int CardSlot,int []pAtrLen,char []pAtrData);
    public native int cardRder_iccExData(int CardSlot, int sendlen, char []psenddata, int []precvlen, char []precvdata);
    public native int cardRder_iccClose(int CardSlot);

    public  int cardRderIccInit(int CardSlot, int CardVol, int CardMode)
    {
		if(READERCARD != 1)
		{
    		return cardRder_iccInit(CardSlot, CardVol, CardMode);
		}
		else
		{
			return -1;
		}
    }
    public  int cardRderIccSelectSlot(int CardSlot)
    {
		if(READERCARD != 1)
		{
    		return cardRder_iccSelectSlot(CardSlot);
		}
		else
		{
			return -1;
		}
    }
    public  int cardRderIccCheckVcc(int CardSlot)
    {
		if(READERCARD != 1)
		{
    		return cardRder_iccCheckVcc(CardSlot);
		}
		else
		{
			return -1;
		}
    }
    public  int cardRderIccCheckInSlot(int CardSlot)
    {
		if(READERCARD != 1)
		{
    		return cardRder_iccCheckInSlot(CardSlot);
		}
		else
		{
			return -1;
		}
    }
    public  int cardRderIccReset(int CardSlot,int []pAtrLen,char []pAtrData)
    {
		if(READERCARD != 1)
		{
    		return cardRder_iccReset(CardSlot, pAtrLen, pAtrData);
		}
		else
		{
			return -1;
		}
    }
    public  int cardRderIccExData(int CardSlot, int sendlen, char []psenddata, int []precvlen, char []precvdata)
    {
		if(READERCARD != 1)
		{
    		return cardRder_iccExData(CardSlot, sendlen, psenddata, precvlen, precvdata);
		}
		else
		{
			return -1;
		}
    }
    public  int cardRderIccClose(int CardSlot)
    {
		if(READERCARD != 1)
		{
    		return cardRder_iccClose(CardSlot);
		}
		else
		{
			return -1;
		}
    }
    
    
    public native int fram_Open();
    public native int fram_Read(int addr, char[] data, int len);
    public native int fram_Write(int addr, char[] data, int len);
    public native int fram_Close();
    public int framOpen()
    {
		if(READERCARD != 1)
		{
    		return fram_Open();
		}
		else
		{
			return -1;
		}
    }
    public int framRead(int addr, char[] data, int len)
    {
		if(READERCARD != 1)
		{
    		return fram_Read(addr, data, len);
		}
		else
		{
			return -1;
		}
    }
    public int framWrite(int addr, char[] data, int len)
    {
		if(READERCARD != 1)
		{
    		return fram_Write(addr, data, len);
		}
		else
		{
			return -1;
		}
    }
    public int framClose()
    {
		if(READERCARD != 1)
		{
    		return fram_Close();
		}
		else
		{
			return -1;
		}
    }
    
    public native int Carder1902_SetRtc(char[] time);
    public native int Carder1902_GetRtc(char[] time);
    public native int Carder1902_SetSn(char[] sn);
    public native int Carder1902_GetSn(char[] sn);
    public native int Carder1902_SetFixSn(char[] sn);
    public native int Carder1902_GetFixSn(char[] sn);
    public native int Carder1902_WDG(int mode);
    public native int Carder1902_WDGSetTime(int time);
    public int Carder1902SetRtc(char[] time)
    {
		if(READERCARD != 1)
		{
    		return Carder1902_SetRtc(time);
		}
		else
		{
			return -1;
		}
    }
    public int Carder1902GetRtc(char[] time)
    {
		if(READERCARD != 1)
		{
    		return Carder1902_GetRtc(time);
		}
		else
		{
			return -1;
		}
    }
    public int Carder1902SetSn(char[] sn)
    {
		if(READERCARD != 1)
		{
    		return Carder1902_SetSn(sn);
		}
		else
		{
			return -1;
		}
    }
    public int Carder1902GetSn(char[] sn)
    {
		if(READERCARD != 1)
		{
    		return Carder1902_GetSn(sn);
		}
		else
		{
			return -1;
		}
    }
    
    public int Carder1902SetFixSn(char[] sn)
    {
		if(READERCARD != 1)
		{
    		return Carder1902_SetFixSn(sn);
		}
		else
		{
			return -1;
		}
    }
    public int Carder1902GetFixSn(char[] sn)
    {
		if(READERCARD != 1)
		{
    		return Carder1902_GetFixSn(sn);
		}
		else
		{
			return -1;
		}
    }
    
    public int Carder1902WDG(int mode)//0-打开 1-关闭
    {
		if(READERCARD != 1)
		{
    		return Carder1902_WDG(mode);
		}
		else
		{
			return -1;
		}
    }
    
    public int Carder1902WDG_SetTime(int time)//0-打开 1-关闭
    {
		if(READERCARD != 1)
		{
    		return Carder1902_WDGSetTime(time);
		}
		else
		{
			return -1;
		}
    }
    
    public native int Carder1902_SM2(char[] key, char[] data, int datalen, char[] result, int[] result_len, int mode);
    public  int Carder1902SM2(char[] key, char[] data, int datalen, char[] result, int[] result_len, int mode)
    {
    	if(READERCARD != 1)
		{
    		return Carder1902_SM2(key, data, datalen, result, result_len, mode);
		}
		else
		{
			return -1;
		}
    }
    
    public native int Carder1902_SetMasterKey(int index, char[] key);
    public native int Carder1902_GetMasterKey(int index, char[] key);
    
    public  int Carder1902SetMasterKey(int index, char[] key)
    {
    	if(READERCARD != 1)
		{
    		return Carder1902_SetMasterKey(index, key);
		}
		else
		{
			return -1;
		}
    }
    
    public  int Carder1902GetMasterKey(int index, char[] key)
    {
    	if(READERCARD != 1)
		{
    		return Carder1902_GetMasterKey(index, key);
		}
		else
		{
			return -1;
		}    	
    }

    public native int Carder1902ClearKeyVal();
    public native int Carder1902GetKeyVal();
    public native int Carder1902GetKeySize();
    public native void Carder1902KeyFuncOpen(int value);

    public int Carder1902_ClearKeyVal()
    {
        if(READERCARD != 1)
        {
            return Carder1902ClearKeyVal();
        }
        else
        {
            return -1;
        }
    }

    public int Carder1902_GetKeyVal()
    {
        if(READERCARD != 1)
        {
            return Carder1902GetKeyVal();
        }
        else
        {
            return -1;
        }       
    }
    
    public int Carder1902_GetKeySize()
    {
        if(READERCARD != 1)
        {
            return Carder1902GetKeySize();
        }
        else
        {
            return -1;
        }       
    }
    
    public void Carder1902_KeyFuncOpen()
    {
        if(READERCARD != 1)
        {
            Carder1902KeyFuncOpen(1);
        } 
    }
    
    public void Carder1902_KeyFuncClose()
    {
        if(READERCARD != 1)
        {
            Carder1902KeyFuncOpen(0);
        }   
    }
    
    private native int PowerStatusGet();
    private native int BattValGet();
    
    public int PowerStatus_Get()
    {
        if(READERCARD != 1)
        {
            return PowerStatusGet();
        }
        else
        {
            return -1;
        }
    }
    
    public int BattVal_Get()
    {
        if(READERCARD != 1)
        {
            return BattValGet();
        }
        else
        {
            return -1;
        }
    }
	public native int qruart_open(int uart_id, int  baud);
    public native int qruart_close(int uart_id);
    public native int qruart_clear(int uart_id);
    public native int qruart_check_readbuf(int uart_id);
    public native int qruart_read(int uart_id, char[] outbuf, int bytelen, int timeout_ms);
    public native int qruart_write(int uart_id, char[] inbuf, int bytelen);
    public native int qruart_write485(int uart_id, char[] inbuf, int bytelen);
    public native int qruart_sel(int uart_id, char mode);
    public native int can_open(char  baud, char mode, int rx0ftaddr, int rx0maskaddr, int rx1ftaddr, int rx1maskaddr);
    public native int can_close();
    public native int can_clear();
    public native int can_check_readbuf();
    public native int can_read(char[] outdata, int bytelen, int timeout_ms);
    public native int can_write(int addr, char mode, char[] databuf, int datalen);
    public native int can_id(char mode);
    
    public int Carder1902_qruart_open(int uart_id, int  baud)
    {
    	if(READERCARD != 1)
		{
    		return qruart_open(uart_id, baud);
		}
		else
		{
			return -1;
		}    
    }
    
    public int Carder1902_qruart_close(int uart_id)
    {
    	if(READERCARD != 1)
		{
    		return qruart_close(uart_id);
		}
		else
		{
			return -1;
		}    	
    }
    
    public int Carder1902_qruart_clear(int uart_id)
    {
    	if(READERCARD != 1)
		{
    		return qruart_clear(uart_id);
		}
		else
		{
			return -1;
		}    	
    	
    }
    
    public int Carder1902_qruart_check_readbuf(int uart_id)
    {
    	if(READERCARD != 1)
		{
    		return qruart_check_readbuf(uart_id);
		}
		else
		{
			return -1;
		}    	
    	
    }
    
    public int Carder1902_qruart_read(int uart_id, char[] outbuf, int bytelen, int timeout_ms)
    {
    	if(READERCARD != 1)
		{
    		return qruart_read(uart_id, outbuf, bytelen, timeout_ms);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_qruart_write(int uart_id, char[] inbuf, int bytelen)
    {
    	if(READERCARD != 1)
		{
    		return qruart_write(uart_id, inbuf, bytelen);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_qruart_write485(int uart_id, char[] inbuf, int bytelen)
    {
    	if(READERCARD != 1)
		{
    		return qruart_write485(uart_id, inbuf, bytelen);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_qruart_sel(int uart_id, char mode)
    {
    	if(READERCARD != 1)
		{
    		return qruart_sel(uart_id, mode);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_CanOpen(char  baud, char mode, int rx0ftaddr, int rx0maskaddr, int rx1ftaddr, int rx1maskaddr)
    {
    	if(READERCARD != 1)
		{
    		return can_open(baud, mode, rx0ftaddr, rx0maskaddr, rx1ftaddr, rx1maskaddr);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_CanClose()
    {
    	if(READERCARD != 1)
		{
    		return can_close();
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_CanClear()
    {
    	if(READERCARD != 1)
		{
    		return can_clear();
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_CanCheckReadBuf()
    {
    	if(READERCARD != 1)
		{
    		return can_check_readbuf();
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_CanRead(char[] outdata, int bytelen, int timeout_ms)
    {
    	if(READERCARD != 1)
		{
    		return can_read(outdata, bytelen, timeout_ms);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_CanWrite(int addr, char mode, char[] databuf, int datalen)
    {
    	if(READERCARD != 1)
		{
    		return can_write(addr, mode, databuf, datalen);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_CanId(char mode)
    {
    	if(READERCARD != 1)
		{
    		return can_id(mode);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public native int attack_set();
    public native int attack_get(char[] statue);
    
    public int Carder1902_Attack_Set()
    {
    	if(READERCARD != 1)
		{
    		return attack_set();
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Carder1902_Attack_Get(char[] statue)
    {
    	if(READERCARD != 1)
		{
    		return attack_get(statue);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public native int Bspatch(char[] oldfile, char[] newfile, char[] patch);
    public native int Bsdiff(char[] oldfile, char[] newfile, char[] patch);

    public native int Carder1902_GetEthMac(char[] mac);
    public native int Carder1902_SetEthMac(char[] mac);


    public int Bs_patch(char[] oldfile, char[] newfile, char[] patch)
    {
    	if(READERCARD != 1)
		{
    		return Bspatch(oldfile, newfile, patch);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public int Bs_diff(char[] oldfile, char[] newfile, char[] patch)
    {
    	if(READERCARD != 1)
		{
    		return Bsdiff(oldfile, newfile, patch);
		}
		else
		{
			return -1;
		}    
    	
    }
    
    public native int VendorStorageRw(int id, int rw, char[] data, int len);
    
    public int vendor_storage_rw(int id, int rw, char[] data, int len)
    {
    	if(READERCARD == 3)
		{
    		return VendorStorageRw(id, rw, data, len);
		}
		else
		{
			return -1;
		}    
    	
    }
}
